Sorry, the browser you are using is not currently supported. Disqus actively supports the following browsers:
This page is forcing your browser to use legacy mode, which is not compatible with Disqus. Please see our troubleshooting guide to get more information about this error.
You are a god among men. Thanks
Incredible detail and clarity. Just what I needed.
You are a god among men. Thanks
You are a god among men. Thanks
You are a god among men. Thanks
Indians, Persians and Africans claim to have invented Chess. yet you term it Western.
India was also first to record dice playing games.
Pachisi originated/started in India by the 6th century
Snakes and Ladders originated in India as part of a family of dice board games
Interesting - good to know! Yes, I put “western” and “eastern” in quotes because it was an overgeneralization.
Spiral Honeycomb Mosaic link is broken
how to print hexagon grid in c++ language
You are a god among men. Thanks
You are a god among men. Thanks :p
I might be wrong but At Defining Algorithm section for Hexagonal Neighbours.. The last neighbours should be (u-1, v-1) instead of (u-1, v+1)?
Hi Mehmet, this will vary depending on how exactly you've set up your coordinate system, but in the one I describe here it's (u-1, v+1). When I update this article I'll include some interactive examples that show why this works.
You are a god among men. Thanks
One thing to note is the total number of vertices, edges and faces. The relation doesn't take into account the total number for programming purposes. After a bit of working out, I've discovered that the number of vertices in total is xy+x where y = number of squares per row, and x = y+1. And the number of edges is equal to:2x^2+2x where x = number of squares per row.
Thanks Alex! This will depend on the shape of your map. I think number of edges will be (number of edges per face) × (number of faces) + ½ of the perimeter, but I'm not sure if that works in every case. For a square map made of x² squares, that'll be 2x² + ½ of 4x, which matches your formula. I don't know if there's a nice generalization for number of vertices.
Perfect amount of detail and explanation, thanks!
hi Amit,
thanks a lot for the articles. i'm research and testing by using a square grid. but there's a problem, how to choose when i found out that there are 2 or more squares have the same F values? which one do i choose? please help.
If you're using A*, you can pick any of the squares with the same F value. It doesn't matter in terms of optimal paths. However you can speed up A* a little bit by breaking the ties. Look at the “Breaking Ties” section of this article.
Hi Amit,
Thanks a lot for your great articles. This is probably a basic question for some of you smart folks out there, but I can't figure out how to calculate hexagon_narrow_width, hexagon_heightand hexagon_wide_width.
I have Googled and checked your other referenced articles, but they seems to use different measurements.
I found someone who referenced your article with these calculations, but I don't see how narrow width and height are the same?
"height" = L√3 "wide width" = L "narrow width" = L√3
Thanks for any assistance!
Hi Ben,
I left those variables undefined because it's specific to each game. The narrow width and the height are *not* the same. It looks like it in the diagram but that's an optical illusion.
If you're using perfect regular hexagons, the lengths will be related with factors of √3. However, in pixel or isometric art, it's common to shrink the hexagon along one of the dimensions, to make it match a desired art style or pixel boundary. That's why I've tried to not hard-code the lengths based on √3. For perfect hexagons, narrow_width = wide_width * ¾ ; height = wide_width * ½ * √3.
Good explained. Thank you.
Very elegantly explained. I will be using your information on Hexagonal grids in a future project. Thank You.
Perhaps you can also add some information on calculating the distance (in number of cells) between any two cells in each of the grids.
That's a good idea Sandip — thanks!